package com.huonan.designpattern.piplie.dts;

import cn.hutool.core.util.HashUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.dfa.WordTree;
import com.huonan.utils.MD5Util;
import com.huonan.utils.SftpUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.logging.log4j.core.util.UuidUtil;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description TODO
 * @Author lxp
 * @Date 2023/2/3 上午11:10
 * @Version V1.0
 **/
@Slf4j
public class DuplicationHandler implements Handler<List<FileEntity>,List<FileEntity>> {


    @Override
    public List<FileEntity> process(List<FileEntity> input) {
        log.info("FetchHandler");
        List<FileEntity> fileList = new ArrayList<>();
            String datePath = "20230419";
            String preSrc = String.format("/bailian/regulation/%s/dianping/dianping.com/",datePath);
            List<String> fileNames = SftpUtil.lsFiles(preSrc);
            for (String file : fileNames) {
                String fileUrl = preSrc+file;
                FileEntity.builder()
                        .status(0)
                        .fileUrl(fileUrl)
                        .id(1);//TODO 自增
            }

        return fileList;
    }

    public static void main(String[] args) {
        String fileUrl = "/bailian/regulation/20230610/dianping/dianping.com/data_xx.zip";
        int r0 = HashUtil.cityHash32(fileUrl.getBytes(StandardCharsets.UTF_8));
        String r1 = SecureUtil.md5(fileUrl);
        String r2 = MD5Util.encryption(fileUrl);
        // Apache
        String r3 = DigestUtils.md5Hex(fileUrl);
        System.out.println(r0);
        System.out.println(r1);
        System.out.println(r2);
        System.out.println(r3);
        long timeBasedUuid = UuidUtil.getTimeBasedUuid().getLeastSignificantBits();
        WordTree tree = new WordTree();


    }
}
